package com.bj.disc.dialog

import android.content.Context
import android.widget.TextView
import com.ai3d.rfid.R
import com.ai3d.rfid.base.dialog.BaseDialog

/**
 * @ProjectName : Trias
 * @Author : weijinsong
 * @Time : 2022/9/30 8:49
 * @Description : 退出登录
 */
class RequestPermissionsDialog(
    var permissions: Int,
    var contextTemp: Context,
    var callback: (isConfirm: Boolean) -> Unit
) :
    BaseDialog(contextTemp, R.style.AlertDialogThemeNoBackground) {
    companion object {
        var RECORD_AUDIO_PERMISSIONS = 1
    }

    private var tvTitle: TextView? = null
    private var tvContent: TextView? = null
    private var tvCancel: TextView? = null
    private var tvConfirm: TextView? = null

    override fun initView() {
        tvTitle = findViewById(R.id.tvTitle)
        tvContent = findViewById(R.id.tvContent)
        tvCancel = findViewById(R.id.tvCancel)
        tvConfirm = findViewById(R.id.tvConfirm)

        when (permissions) {
            RECORD_AUDIO_PERMISSIONS -> {
                tvTitle?.setText(R.string.record_audio_permissions_title)
                tvContent?.setText(R.string.record_audio_permissions_tips)
            }
        }
    }

    override fun initEvent() {
        tvCancel?.setOnClickListener {
            callback?.invoke(false)
            dismiss()
        }
        tvConfirm?.setOnClickListener {
            dismiss()
            callback?.invoke(true)
        }
    }

    override fun initData() {

    }

    override fun getLayoutId(): Int {
        return R.layout.dialog_request_permission
    }

    override fun getAnimId(): Int {
        return -1
    }
}